package com.xuecheng.manage_course.controller;

import com.xuecheng.api.course.CoursePicControllerApi;
import com.xuecheng.framework.domain.course.CoursePic;
import com.xuecheng.framework.model.response.ResponseResult;
import com.xuecheng.manage_course.service.CoursePicService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RequestMapping("/course/coursepic/")
@RestController
public class CoursePicController implements CoursePicControllerApi {
    @Resource
    CoursePicService coursePicService;

    /**
     * 添加课程图片
     *
     * @param courseId 课程id
     * @param pic      课程图片地址
     * @return 响应结果
     */
    @Override
    @PostMapping("/add")
    public ResponseResult addCoursePic(@RequestParam("courseId") String courseId, @RequestParam("pic") String pic) {
        return coursePicService.addCoursePic(courseId,pic);
    }

    /**
     * 查询课程图片
     *
     * @param courseId 课程id
     * @return 响应结果
     */
    @Override
    @GetMapping("/list/{courseId}")
    public CoursePic findCoursePic(@PathVariable("courseId") String courseId) {
        return coursePicService.findCoursePic(courseId);
    }

    /**
     * 删除课程图片
     *
     * @param courseId 课程id
     * @return 响应结果
     */
    @Override
    @DeleteMapping("/delete")
    public ResponseResult deleteCoursePic(@RequestParam("courseId") String courseId) {
        return coursePicService.deleteCoursePic(courseId);
    }
}
